package thread;

public class demo16 {
    private static Object obj = new Object();
    public static void main(String[] args) {

        Thread t = new Thread(() -> {
            synchronized (obj) {
                    System.out.println("t: wait前");
                try {
                    obj.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t: wait之后");
                obj.notify();
            }

        });
        Thread t2 = new Thread(() -> {
            synchronized (obj) {
                    System.out.println("t2: wait前");
                try {
                    obj.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t2: wait之后");
                obj.notify();
            }

        });
        Thread t1 = new Thread(() -> {
            synchronized (obj) {
                System.out.println("notify");
                obj.notify();
            }

        });
        t.start();
        t1.start();
        t2.start();

    }
}
